<!--conf
<sample in_favorites="true">
              <product version="1.6" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               <sampledescription><![CDATA[Use autocalculated values to do usual calculations in treegrid footer]]></sampledescription></sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Aggregation in TreeGrid</title>
	<link rel="STYLESHEET" type="text/css" href="../../../dhtmlxGrid/codebase/dhtmlxgrid.css">
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
	<script  src="../../codebase/dhtmlxtreegrid.js"></script>
	<script src="../../codebase/ext/dhtmlxtreegrid_filter.js" type="text/javascript"></script>
	<style>
	div.gridbox div.ftr td{
			text-align:right;
						
		}
		div.gridbox table.hdr td {
		background-color:#ffcc90;
	
		font-weight:bold;
		}
	</style>
	
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxtreegrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxTreeGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>Aggregation in TreeGrid</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxTreeGrid/index.shtml">dhtmlxTreeGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	
	<p>
    TreeGrid allows to calculate a sum, an average, a minimum and a maximum of each column.
	</p>
	
	
	<table width="835">
		<tr>
			<td>
				<div id="gridbox" width="320px" height="410px" style="background-color:white;"></div>
			</td>
            <td>
				<div id="gridbox1" width="320px" height="410px" style="background-color:white;"></div>
			</td>
		</tr>
	</table>

<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">div</span><span class="hl-code"> </span><span class="hl-var">id</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">gridbox</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">width</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100%</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">height</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">250px</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">style</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">background-color:white;overflow:hidden</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">&gt;</span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">div</span><span class="hl-brackets">&gt;</span><span class="hl-code">
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span><span class="hl-code"><div class="hl-main"><pre><span class="hl-code"> 
    </span><span class="hl-comment">/*</span><span class="hl-comment">total filtering</span><span class="hl-comment">*/</span><span class="hl-code">
    </span><span class="hl-identifier">mygrid</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">dhtmlXGridObject</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gridbox</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
        ...
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Total:,${#stat_tree_total},{#stat_tree_total}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Multi total:,${#stat_tree_multi_total}1:2,{#stat_tree_multi_total}1:2</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Maximum:,${#stat_tree_max},{#stat_tree_max}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Minimum:,${#stat_tree_min},{#stat_tree_min}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Average:,${#stat_tree_average},{#stat_tree_average}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Count:,{#stat_tree_count},#cspan</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    
    </span><span class="hl-comment">/*</span><span class="hl-comment">leaves filtering</span><span class="hl-comment">*/</span><span class="hl-code">
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">dhtmlXGridObject</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gridbox1</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    ...
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Total leaves:,${#stat_tree_total_leaf},{#stat_tree_total_leaf}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Multi total leaves:,${#stat_tree_multi_total_leaf}1:2,{#stat_tree_multi_total_leaf}1:2</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Maximum leaves:,${#stat_tree_max_leaf},{#stat_tree_max_leaf}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Minimum leaves:,${#stat_tree_min_leaf},{#stat_tree_min_leaf}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Average leaves:,${#stat_tree_average_leaf},{#stat_tree_average_leaf}</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid1</span><span class="hl-code">.</span><span class="hl-identifier">attachFooter</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Count leaves:,{#stat_tree_count_leaf},#cspan</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;</span></pre></div></span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span></pre></div></div>

<script>

//background-color:#ffcc66;
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/icons_books/");
	mygrid.setHeader("Title,Price,Quantity");
	mygrid.setInitWidths("200,62,*")
	mygrid.setColAlign("left,right,right")
	mygrid.setColTypes("tree,price,ed");
	mygrid.setColSorting("str,int,int")
	//mygrid.setColumnColor("#d5f1ff")
 
	mygrid.init();
	
	mygrid.loadXML("treegrid_sample.xml");
	mygrid.attachFooter('Total:,${#stat_tree_total},{#stat_tree_total}');
	mygrid.attachFooter('Multi total:,${#stat_tree_multi_total}1:2,{#stat_tree_multi_total}1:2');
	mygrid.attachFooter('Maximum:,${#stat_tree_max},{#stat_tree_max}');
	mygrid.attachFooter('Minimum:,${#stat_tree_min},{#stat_tree_min}');
	mygrid.attachFooter('Average:,${#stat_tree_average},{#stat_tree_average}');
	mygrid.attachFooter('Count:,{#stat_tree_count},#cspan');
	
	mygrid1 = new dhtmlXGridObject('gridbox1');
	mygrid1.setImagePath("../../../dhtmlxGrid/codebase/imgs/icons_books/");
	mygrid1.setHeader("Title,Price,Quantity");
	mygrid1.setInitWidths("200,62,*")
	mygrid1.setColAlign("left,right,right")
	mygrid1.setColTypes("tree,price,ed");
	mygrid1.setColSorting("str,int,int")
	//mygrid1.setColumnColor("#d5f1ff")
 
	mygrid1.init();
	
	mygrid1.loadXML("treegrid_sample.xml");
	mygrid1.attachFooter('Total leaves:,${#stat_tree_total_leaf},{#stat_tree_total_leaf}');
	mygrid1.attachFooter('Multi total leaves:,${#stat_tree_multi_total_leaf}1:2,{#stat_tree_multi_total_leaf}1:2');
	mygrid1.attachFooter('Maximum leaves:,${#stat_tree_max_leaf},{#stat_tree_max_leaf}');
	mygrid1.attachFooter('Minimum leaves:,${#stat_tree_min_leaf},{#stat_tree_min_leaf}');
	mygrid1.attachFooter('Average leaves:,${#stat_tree_average_leaf},{#stat_tree_average_leaf}');
	mygrid1.attachFooter('Count leaves:,{#stat_tree_count_leaf},#cspan');
	
	
</script>


<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
